tdf#113946 add 'topMargin' to GraphicHelpers import
The case '...topMargin' was not caught for setting a relative
vertical position in GraphicHelpers. The test file demands a '7' here,
which stands for 'PAGE_FRAME'. The '7' was overwritten in GraphicImport in case
'LN_CT_Anchor_positionV' by a call of 'resolve'.
For a better overview a switch is inserted here.
Change-Id: Ie98209fe445ecbba15c3dafe5980ca52421126f8
Reviewed-on: https://gerrit.libreoffice.org/47905
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
diff --git a/sw/qa/extras/ooxmlimport/data/tdf113946.docx b/sw/qa/extras/ooxmlimport/data/tdf113946.docx
new file mode 100644
index 0000000..060df76
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf113946.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 4d65bee..449dae0 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1567,6 +1567,13 @@ DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx")
CPPUNIT_ASSERT_EQUAL( OUString("30624"), aTop );
}
DECLARE_OOXMLIMPORT_TEST(testTdf113946, "tdf113946.docx")
{
OUString aTop = parseDump("/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "top");
CPPUNIT_ASSERT_EQUAL( OUString("1696"), aTop );
}
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index 8108445..a7ce018 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.cxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.cxx
@@ -63,57 +63,59 @@ void PositionHandler::lcl_attribute( Id aName, Value& rVal )
{
case NS_ooxml::LN_CT_PosV_relativeFrom:
{
// TODO There are some other unhandled values
static const Id pVertRelValues[] =
switch ( nIntValue )
{
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_margin,
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page,
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_paragraph,
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_line
};
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_margin:
m_nRelation = text::RelOrientation::PAGE_PRINT_AREA;
break;
static const sal_Int16 pVertRelations[] =
{
text::RelOrientation::PAGE_PRINT_AREA,
text::RelOrientation::PAGE_FRAME,
text::RelOrientation::FRAME,
text::RelOrientation::TEXT_LINE
};
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page:
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_topMargin: // fallthrough intended
m_nRelation = text::RelOrientation::PAGE_FRAME;
break;
for ( int i = 0; i < 4; i++ )
{
if ( pVertRelValues[i] == sal_uInt32( nIntValue ) )
m_nRelation = pVertRelations[i];
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_paragraph:
m_nRelation = text::RelOrientation::FRAME;
break;
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_line:
m_nRelation = text::RelOrientation::TEXT_LINE;
break;
// TODO There are some other unhandled values
}
}
break;
case NS_ooxml::LN_CT_PosH_relativeFrom:
{
// TODO There are some other unhandled values
static const Id pHoriRelValues[] =
switch ( nIntValue )
{
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_margin,
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page,
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_column,
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_character,
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_leftMargin,
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_rightMargin
};
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_margin:
m_nRelation = text::RelOrientation::PAGE_PRINT_AREA;
break;
static const sal_Int16 pHoriRelations[] =
{
text::RelOrientation::PAGE_PRINT_AREA,
text::RelOrientation::PAGE_FRAME,
text::RelOrientation::FRAME,
text::RelOrientation::CHAR,
text::RelOrientation::PAGE_LEFT,
text::RelOrientation::PAGE_RIGHT,
};
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page:
m_nRelation = text::RelOrientation::PAGE_FRAME;
break;
for ( int i = 0; i < 6; i++ )
{
if ( pHoriRelValues[i] == sal_uInt32( nIntValue ) )
m_nRelation = pHoriRelations[i];
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_column:
m_nRelation = text::RelOrientation::FRAME;
break;
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_character:
m_nRelation = text::RelOrientation::CHAR;
break;
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_leftMargin:
m_nRelation = text::RelOrientation::PAGE_LEFT;
break;
case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_rightMargin:
m_nRelation = text::RelOrientation::PAGE_RIGHT;
break;
// TODO There are some other unhandled values
}
}
break;